<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  <input type="text" class="search">
  <ul class="list">
  </ul>
</body>
<script src="./jsonp.js"></script>
<script>


  $(".search").oninput = function(){
    if(this.value === ""){
      $(".list").innerHTML = "";
      return;
    }
    jsonp({
      url:"https://www.baidu.com/sugrec",
      data: {
        pre:1,
        p:3,
        ie:"utf-8",
        json:1,
        prod:"pc",
        from:"pc_web",
        sugsid:"38516,36545,38686,38860,38798,38903,38793,38841,38804,38840,38640,26350",
        wd: this.value,
        req:2,
        csor:6,
        cb:"ajhdsgffdhs4rt",
        _:Date.now()
      },
      success(res){
        let str = "";
        res.g.forEach(val=>{
          str += `<li>${val.q}</li>`
        })
        $(".list").innerHTML = str;
      },
      jsonpName:"cb"
    })
  }

  function $(s){
    return document.querySelector(s)
  }

</script>
</html>